﻿/// <reference path="2.chunk.min.js" />
/// <reference path="2.chunk.min.js" />
!
function (t, e) {
    "object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.html5ImgCompress = e() : t.html5ImgCompress = e()
}(this, function () {
    return function (t) {
        function e(n) {
            if (i[n]) return i[n].exports;
            var o = i[n] = {
                exports: {},
                id: n,
                loaded: !1
            };
            return t[n].call(o.exports, o, o.exports, e), o.loaded = !0, o.exports
        }
        var n = window.webpackJsonphtml5ImgCompress;
        window.webpackJsonphtml5ImgCompress = function (i, a) {
            for (var r, h, d = 0, s = []; d < i.length; d++) h = i[d], o[h] && s.push.apply(s, o[h]), o[h] = 0;
            for (r in a) t[r] = a[r];
            for (n && n(i, a) ; s.length;) s.shift().call(null, e)
        };
        var i = {},
			o = {
			    3: 0
			};
        return e.e = function (t, n) {
            if (0 === o[t]) return n.call(null, e);
            if (void 0 !== o[t]) o[t].push(n);
            else {
                o[t] = [n];
                var i = document.getElementsByTagName("head")[0],
					a = document.createElement("script");
                
                //a.type = "text/javascript", a.charset = "utf-8", a.async = !0, a.src = e.p + "" + t + ".chunk.min.js", i.appendChild(a)
                //a.type = "text/javascript", a.charset = "utf-8", a.async = !0, a.src = "~/Content/Scripts/Area/Origins/Material/2.chunk.min.js", i.appendChild(a)

            }
        }, e.m = t, e.c = i, e.p = "", e(0)
    }([function (t, e, n) {
        var i, o;
        i = [], o = function () {
            function t(e, n) {
                var i = t.DEFAULTE;
                this.file = e, this.options = {};
                for (var o in i) this.options[o] = null == n[o] ? i[o] : n[o];
                this.init()
            }
            var e = navigator.userAgent,
				i = ~e.indexOf("MicroMessenger"),
				o = ~e.indexOf("Android"),
				a = function () {
				    var t = navigator.userAgent.match(/(\d)_\d like Mac OS/);
				    return t && t[1] <= 7
				}(),
				r = window.URL || window.webkitURL,
				h = document.scripts,
				d = h[h.length - 1].src;
            return n.p = d.substr(0, d.lastIndexOf("/") + 1), t.prototype = {
                init: function () {
                    r && File && document.createElement("canvas").getContext ? this.read(this.file) : this.options.notSupport()
                },
                read: function (t) {
                    var e, h, d, s, c, u, l, p, f, g = this,
						m = new Image,
						w = r.createObjectURL(t);
                    g.options.before(t) !== !1 && (m.src = w, m.onload = function () {
                        p = function (r) {
                            if (c = g.options.quality, e = g.getSize(m, r), h = document.createElement("canvas"), h.width = e.width, h.height = e.height, d = h.getContext("2d"), a) n.e(0, function (e) {
                                var n = [e(3)];
                                (function (e) {
                                    s = new e(m), f = {
                                        maxWidth: h.width,
                                        maxHeight: h.height,
                                        orientation: r
                                    }, ~"68".indexOf(r) && (f.maxWidth = h.height, f.maxHeight = h.width), s.render(h, f), l = h.toDataURL("image/jpeg", c), g.handler("done", h, m, w, l, t)
                                }).apply(null, n)
                            });
                            else {
                                switch (r) {
                                    case 3:
                                        d.rotate(180 * Math.PI / 180), d.drawImage(m, -h.width, -h.height, h.width, h.height);
                                        break;
                                    case 6:
                                        d.rotate(90 * Math.PI / 180), d.drawImage(m, 0, -h.width, h.height, h.width);
                                        break;
                                    case 8:
                                        d.rotate(270 * Math.PI / 180), d.drawImage(m, -h.height, 0, h.height, h.width);
                                        break;
                                    default:
                                        d.drawImage(m, 0, 0, h.width, h.height)
                                }
                                o && i ? n.e(1, function (e) {
                                    var n = [e(2)];
                                    (function (e) {
                                        u = new e, l = u.encode(d.getImageData(0, 0, h.width, h.height), 100 * c), g.handler("done", h, m, w, l, t)
                                    }).apply(null, n)
                                }) : l = h.toDataURL("image/jpeg", c), g.handler("done", h, m, w, l, t)
                            }
                        }, o ? p() : n.e(2, function (t) {
                            var e = [t(1)];
                            (function (t) {
                                t.getData(m, function () {
                                    p(t.getTag(this, "Orientation"))
                                })
                            }).apply(null, e)
                        })
                    }, m.onerror = function () {
                        g.handler("fail", h, m, w, l, t)
                    })
                },
                handler: function (t, e, n, i, o, a) {
                    e = null, n = null, r.revokeObjectURL(i), this.options[t](a, o), this.options.complete(a)
                },
                getSize: function (t, e) {
                    var n, i = this.options,
						o = i.maxWidth,
						a = i.maxHeight,
						r = t.width,
						h = t.height;
                    return ~"68".indexOf(e) && (r = t.height, h = t.width), n = r / h, o && a ? n >= o / a ? r > o && (h = o / n, r = o) : h > a && (r = a * n, h = a) : o ? o < r && (h = o / n, r = o) : a && a < h && (r = a * n, h = a), {
                        width: r,
                        height: h
                    }
                }
            }, t.DEFAULTE = {
                maxWidth: 1e3,
                maxHeight: 1e3,
                quality: .6,
                before: function () { },
                done: function () { },
                fail: function () { },
                complete: function () { },
                notSupport: function () { }
            }, window.html5ImgCompress = t
        }.apply(e, i), !(void 0 !== o && (t.exports = o))
    }])
});